package com.treasure.gateway.config;

import com.treasure.gateway.handler.ImageCodeHandler;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;

/**
 * 路由配置信息
 *
 * @author 时前程
 * @create 2020-03-04 13:45
 * @Version V1.0
 **/
@Slf4j
@Configuration
@AllArgsConstructor
public class RouterFunctionConfiguration {
    private final ImageCodeHandler imageCodeHandler;

    @Bean
    public RouterFunction routerFunction(){

        return RouterFunctions.route(
                RequestPredicates.GET("/code")
                .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),imageCodeHandler
        );
    }
}
